﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using ERP_RORZE_SYSTEM;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ERP_RORZE_DLL.Business
{
    public partial class panel_RZConsumption : UserControl
    {
        
        public panel_RZConsumption()
        {
            InitializeComponent();
            LoadData();
        }

        //////////////////////////////////////////////
        /// Load Data to Grid View
        //////////////////////////////////////////////
        private void LoadData()
        {
            DataSet sourceDataSet = new DataSet();
            INISettings mySettings = new INISettings();
            SQLManagement mySQLManagement = new SQLManagement();
            mySQLManagement.SQLConnectionString = mySettings.SQLConnectionString;
            string sql = "SELECT * FROM [241_RZConsumption]";
            sourceDataSet = mySQLManagement.SQL_Query(sql);
            if (sourceDataSet != null)
            {
                gridRZConsumption.DataSource = sourceDataSet.Tables[0];
            }
            else
            {
                DataTable newTable = new DataTable();
                newTable.Columns.Add("ID", typeof(int));
                newTable.Columns.Add("RZNo", typeof(string));
                newTable.Columns.Add("IQNo", typeof(string));
                newTable.Columns.Add("TotalQuantity", typeof(float));
                newTable.Columns.Add("MassQuantity", typeof(float));
                newTable.Columns.Add("NetQuantity", typeof(float));
                gridRZConsumption.DataSource = newTable;
            }
            RZConsumption.Columns[0].Caption = "ID";
            RZConsumption.Columns[1].Caption = "RZ Code";
            RZConsumption.Columns[2].Caption = "IQ No";
            RZConsumption.Columns[3].Caption = "Robot Quantity";
            RZConsumption.Columns[4].Caption = "Mass Quantity";
            RZConsumption.Columns[5].Caption = "Net Quantity";
            RZConsumption.Columns[0].Visible = false;
            RZConsumption.BestFitColumns();
        }
    }
}
